rombios: compute checksum for roms bigger than a segment
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 4 Jun 2009 09:36:01 +0000 (10:36 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 4 Jun 2009 09:36:01 +0000 (10:36 +0100)
From: Glauber Costa <glommer@redhat.com>
From: "Sebastian Herbszt" <herbszt@gmx.de>
Ported by: Akio Takebe <takebe_akio@jp.fujitsu.com>

tools/firmware/rombios/rombios.c

index 94f9a9b521e98756a0332746745008c4d35c323a..2d97a401d52449825a564cc915703ee13e07c94c 100644 (file)
@@ -10439,22 +10439,44 @@ no_serial:
   ret
 
 rom_checksum:
-  push ax
-  push bx
-  push cx
+  pusha
+  push ds
+
   xor  ax, ax
   xor  bx, bx
   xor  cx, cx
+  xor  dx, dx
+
   mov  ch, [2]
   shl  cx, #1
+
+  jnc checksum_loop
+  jz  checksum_loop
+  xchg dx, cx
+  dec  cx
+
 checksum_loop:
   add  al, [bx]
   inc  bx
   loop checksum_loop
+
+  test dx, dx
+  je checksum_out
+
+  add  al, [bx]
+  mov  cx, dx
+  mov  dx, ds
+  add  dh, #0x10
+  mov  ds, dx
+  xor  dx, dx
+  xor  bx, bx
+
+  jmp  checksum_loop
+
+checksum_out:
   and  al, #0xff
-  pop  cx
-  pop  bx
-  pop  ax
+  pop  ds
+  popa
   ret